#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
ll n, a[N], b[N], cnt[N], k[N], pos, ans;
bool flag = false;
int main()
{
    ios::sync_with_stdio(false);
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    cin >> n;
    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (a[i] != 1 && a[i] != 2)
            flag = true;
    }
    if (flag && n <= 10)
    {
        sort(a + 1, a + 1 + n);
        for (ll i = 1; i <= n; i++)
        {
            if (b[pos] != a[i])
                b[++pos] = a[i];
            cnt[pos]++;
        }
        for (ll i = pos - 1; i >= 1; i--)
            k[i] = k[i + 1] + cnt[i];
        ans = k[1];
        for (ll i = 2; i <= pos; i++)
            ans -= k[i];
        cout << ans << "\n";
    }
    else if (!flag)
    {
        for (ll i = 1; i <= n; i++)
        {
            if (a[i] == 1)
                cnt[1]++;
            else
                cnt[2]++;
        }
        cout << n - min(cnt[1], cnt[2]) << "\n";
    }
    else
        cout << 0 << "\n";
    return 0;
}